#pragma once

#include "imageclip.h"
#include "panel.h"
#include "button.h"
#include "masterpanel.h"

class ImageButton : public Button
{
protected:
	// what to draw in this button (if anything)
	ImageClip m_clip;
public:
	inline ImageClip getClip(){return m_clip;}
	void setButtonImage(const ImageClip & a_clip)
	{
		m_clip=a_clip;
		getArea()->setDimension(a_clip.clip.getDimension());
	}
	void draw(SDL_Surface * a_surface)
	{
		// must use copy of area because SDL_FillRect modifies the value...
		SRect area(*getArea());
		VSDL_FillRect(a_surface, &area, 
			getMasterPanel()->getColor((isOn()||(isOver()&&isPressed()))
			?MasterPanel::COLOR_ACTIVE
			:MasterPanel::COLOR_BG));
		area.set(*getArea());
		m_clip.draw(a_surface, area.getMin(), ImageClip::DEFAULT_TRANSPARENT_INDEX);
	}
	void copy(const ImageButton & b)
	{
		m_clip = b.m_clip;
		Button::copy(b);
	}
};